import React, { Component } from 'react'
import * as Sentry from '@sentry/browser';
import config from "../../utils/config";
// Sentry.init has to be called in the somewhere before

export default class Sen extends Component {
  constructor(props) {
    super(props);
    this.state = { error: null };
  }
  componentDidMount(){
    // let dsnSentry = 'https://b0570c4d4cb04267abd9379db1e0bc40@sentry.io/1289590'
    // let dsnSentry = 'https://ffaddb3c4f0047aea1333e64b4a4a199@sentry.io/1301855'
    Sentry.init({ dsn: config.dsnSentry });
  }


  componentDidCatch(error, errorInfo) {
    this.setState({ error });
    Sentry.configureScope(scope => {
      Object.keys(errorInfo).forEach(key => {
        scope.setExtra(key, errorInfo[key]);
      });
    });
    Sentry.captureException(error);
  }

  render() {
    return this.props.children;
  }
}

